#ifndef EMS_SUMMARY_H
#define EMS_SUMMARY_H

#include "receive_processor.h"
#include "databasemanager.h"
#include "devicemonitor.h"
#include "serialtoolwidget.h"
#include "qcustomplot.h"


#include <QWidget>
#include <QVBoxLayout>
#include <QLabel>
#include <QChartView>
#include <QTimer>
#include <QPieSeries>
#include <QLineSeries>
#include <QRandomGenerator>
#include <QListWidget>
#include <QGroupBox>
#include <QValueAxis>
#include <QRegExp>
#include <QSoundEffect>



class EMS_Summary : public QWidget
{
    Q_OBJECT
public:
    explicit EMS_Summary(QWidget *parent = nullptr);
    void setupUI();
    void setupConnections();
    QWidget* createTopInfoWidget();
    QWidget* createChartWidget();
    QWidget* createDeviceStatusWidget();
    QCustomPlot* createLineChart();
    QChart* createPieChart();
    QLabel* createInfoLabel(const QString &title, const QString &value, const QString &color);

    // 成员变量
    QLabel *lblTotal;
    QLabel *lblPower;
    QLabel *lblCarbon;

    QLabel *Warning_Light;//警报灯图片显示
    QPixmap *L_green;//绿色显示灯
    QPixmap *L_red;//红色显示灯
    QPixmap *L_gray;//灰色显示灯
    QPixmap *L_yellow;//黄色显示灯

    DeviceMonitor *device_monitor;
    SerialToolWidget *serial_tool_widget;
    QList<QListWidgetItem*>*device_status;

    QPieSeries *pie_series;
    QSoundEffect *alarm_sound;
public slots:
    ///更新数据总结性面板的数据
    ///不同页面按照不同的定时器
    /// 实时数据
    void update_current_active_power();
    /// 今日数据
    void update_today_active_power();
    /// 24小时数据
    void update_line_chart();


private:
    QTimer *current_ap_timer;
    QTimer *todays_ap_timer;
    QTimer *line_chart_ap_timer;
    QLineSeries *series;
    QChart *chart_Line;
    QValueAxis *axisX;
    QValueAxis *axisY;
signals:
};

#endif // EMS_SUMMARY_H
